import java.util.Arrays;

public class text {
    //算法题：移动零；
    public static void fun(int[] array){
        for(int cur=0,dest=-1;cur<array.length;cur++){
            if(array[cur]!=0){
                dest++;
                int tmp=array[cur];
                array[cur]=array[dest];
                array[dest]=tmp;
            }
        }
    }
    public static void main(String[] args) {
        int[] array = {0, 1, 0, 3, 12};
        fun(array);
        System.out.println(Arrays.toString(array));
    }
}
